#include "BlockModel.h"
#include "blockSide.h"
#include "base.h"
#include "stdgeom.h"
#include "constant.h"
#include "Utils.h"

BlockModel::BlockModel(void)
{
	m_bInitialized = false;
	m_sideVBuffers = new ModelVBO[SIDE_COUNT];
}
BlockModel::~BlockModel(void)
{
	ADelete(m_sideVBuffers);
}
void BlockModel::Initialize()
{
	if(m_bInitialized)
		return; // Already initialized

	for(int i = 0; i < SIDE_COUNT; i++)
	{
		m_sideVBuffers[i].Create(cubeSidePoints[i], cubeSideNormals[i], cubeTexCoords, cubeSideElementCount);
	}

	m_bInitialized = true;
}
void BlockModel::SetCustomPointers(int vertexPointer, int normalPointer, int texcoordPointer)
{
	for(int i = 0; i < SIDE_COUNT; i++)
	{
		m_sideVBuffers[i].SetCustomPointers(vertexPointer, normalPointer, texcoordPointer);
	}
}
ModelVBO *BlockModel::GetSides()
{
	return m_sideVBuffers;
}
void BlockModel::RenderBlockSide(uint blockSide)
{
	m_sideVBuffers[blockSide].CustomBind();
	glDrawArrays(GL_TRIANGLE_STRIP, 0, m_sideVBuffers[blockSide].GetElementCount());

}